package com.clip.dao;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Repository;

import com.clip.entity.UserEmailCollection;

@Repository
public class UserEmailCollectionDAO extends BasicDao{
	private static final Log log = LogFactory.getLog(UserEmailCollection.class);
	
	public void save(UserEmailCollection transientInstance) {
		log.debug("saving UserEmailCollection instance");
		try {
			this.getSession().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}
	public void saveNotExists(UserEmailCollection transientInstance){
		String hql = "SELECT uec FROM UserEmailCollection uec WHERE uec.email='"+transientInstance.getEmail()+"'";
		if(this.getSession().createQuery(hql).list().size()<=0)
			save(transientInstance);
	}
}
